package cn.echoedu.util;

import java.io.UnsupportedEncodingException;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

public class HttpUtil {
	private final static String T="HttpUtil";
	/**
	 * ��ȡ�ͻ��˷�����json�����ַ�
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException 
	 */
 public synchronized static String readJSONString(ServletRequest request){
	 L.p(T+"readJSONString");
	  StringBuffer jsonstring=new StringBuffer();
	  String line=null;
	  try{
		  request.setCharacterEncoding("utf-8");
		  jsonstring.append(request.getParameter("param"));
//		  BufferedReader reader=request.getReader();
//		  while((line=reader.readLine())!=null){
//			  jsonstring.append(line);
//			 
//		  }
		 
		  
	  }catch(Exception e){
		  L.p(T+"readJSONString Exception");
		  e.printStackTrace();
	  }
	  String result = null;
	try {
		result = java.net.URLDecoder.decode(jsonstring.toString(),"utf-8");
	} catch (UnsupportedEncodingException e) {
		// TODO Auto-generated catch block
		L.p(T+"error result error");
		e.printStackTrace();
	}
//	L.p(T+"jsonstr:"+result);
	return result;
	  
  }

}

